<template>
  <div class="unit_payment">
    <div class="header_title">
      <span>手机端权限配置</span>
    </div>
    <div class="list">
      <el-form
        ref="alldata"
        :model="alldata"
        :rules="alldatarule"
        :label-position="labelPosition"
        label-width="180px"
        class="clearfix"
      >
              <el-col :span="12">
          <el-form-item label="手机端是否可以新增学生:" >
            <el-col :span="4">
              <el-switch
                v-model="alldata.phoneAddUser"
                active-text="是"
                inactive-text="否"
                :active-value="1"
                :inactive-value="0"
              ></el-switch>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="姓名是否可以修改:">
            <el-col :span="4">
              <el-switch
                v-model="alldata.nameModify"
                active-text="是"
                inactive-text="否"
                :active-value="1"
                :inactive-value="0"
              ></el-switch>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="性别是否可以修改:">
            <el-col :span="4">
              <el-switch
                v-model="alldata.sexModify"
                active-text="是"
                inactive-text="否"
                :active-value="1"
                :inactive-value="0"
              ></el-switch>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="学号是否可以修改:">
            <el-col :span="4">
              <el-switch
                v-model="alldata.userNumberModify"
                active-text="是"
                inactive-text="否"
                :active-value="1"
                :inactive-value="0"
              ></el-switch>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="班级是否可以修改:">
            <el-col :span="4">
              <el-switch
                v-model="alldata.departmentModify"
                active-text="是"
                inactive-text="否"
                :active-value="1"
                :inactive-value="0"
              ></el-switch>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="登录名是否可以修改:">
            <el-col :span="4">
              <el-switch
                v-model="alldata.loginModify"
                active-text="是"
                inactive-text="否"
                :active-value="1"
                :inactive-value="0"
              ></el-switch>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="手机号是否可以修改:">
            <el-col :span="4">
              <el-switch
                v-model="alldata.phoneModify"
                active-text="是"
                inactive-text="否"
                :active-value="1"
                :inactive-value="0"
              ></el-switch>
            </el-col>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="宿管配置是否开启:">
            <el-col :span="4">
              <el-switch
                v-model="alldata.hostConfiguration"
                active-text="是"
                inactive-text="否"
                :active-value="1"
                :inactive-value="0"
              ></el-switch>
            </el-col>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="归宿设置范围:">
            <el-col :span="12">
              <el-select
                v-model="alldata.hostModify"
                placeholder="请选择"
                size="mini"
                :disabled="!alldata.hostConfiguration == 1"
              >
                <el-option
                  v-for="item in hostModifylist"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-col>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="身份证是否可以修改:">
            <el-col :span="4">
              <el-switch
                v-model="alldata.idCardModify"
                active-text="是"
                inactive-text="否"
                :active-value="1"
                :inactive-value="0"
              ></el-switch>
            </el-col>
          </el-form-item>
        </el-col>

        
        <el-col :span="12">
          <el-form-item>
            <el-button type="primary" @click="onSubmit()">保存信息</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      labelPosition: 'right',
      alldata: {
        departmentModify: 0,
        hostConfiguration: 0,
        hostModify: 0,
        idCardModify: 0,
        insertTime: '',
        lastUpdate: '',
        loginModify: 0,
        phoneModify: 0,
        pkConfgId: 0,
        sexModify: 0,
        unitGuid: '',
        userNumberModify: 0
      },
      hostModifylist: [
        { label: '全部', value: 1 },
        { label: '楼栋', value: 2 },
        { label: '楼层', value: 3 },
        { label: '房间', value: 4 }
      ],
      userGuid: '',
      alldatarule: {}
    }
  },
  created() {
    this.userGuid = sessionStorage.getItem('administrator')
  },
  computed: {
    changeschoolid: {
      get() {
        return this.$store.state.user.changeschoolid
      }
    }
  },
  mounted() {
    this.getH5Rateuser()
  },
  methods: {
    //获取支付信息配置
    getH5Rateuser() {
      this.$http({
        url: this.$http.adornUrl('/unit/unit-user-config-search'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            unitGuid: this.changeschoolid,
            userGuid: this.userGuid
          },
          messageType: this.messageType
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          if (data.messageContent) {
            this.alldata = { ...data.messageContent }
          }
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    },
    onSubmit() {
      this.$http({
        url: this.$http.adornUrl('/unit/unit-user-config-update'),
        method: 'post',
        data: this.$http.adornData({
          messageContent: {
            ...this.alldata
          },
          messageType: this.messageType
        })
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          this.$message({
            showClose: true,
            message: '配置成功',
            type: 'success'
          })
          this.getH5Rateuser()
        } else {
          this.$message.error(data.errorMessage)
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.el-checkbox + .el-checkbox {
  margin-left: 0;
}
.unit_payment {
  padding: 10px;
  //   min-width: 500px;
  .clearfix:after {
    content: '.';
    clear: both;
    height: 0;
    overflow: hidden;
    visibility: hidden;
    display: block;
  }
  .clearfix {
    zoom: 1;
  }
  .header_title {
    // padding-left: 22px;
    height: 50px;
    line-height: 50px;
    border-bottom: 1px solid #e5e9f2;
    color: #909399;
  }
  .list {
    font-size: 16px;
    font-weight: bold;
    color: #909399;
    padding-top: 20px;
    .el-form-item {
      padding-left: 22px;
      // padding-top: 5px;
      height: 50px;
      line-height: 70px;
      margin-bottom: 0px;
      width: 100%;
    }
    .el-form-item:last-child {
      border-bottom: 0px solid #e5e9f2;
    }
  }
  .fanshionable_title {
    margin-top: 20px;
    padding-left: 22px;
    height: 30px;
    color: #909399;
    border-bottom: 1px solid #e5e9f2;
  }
  .fanshionable_list {
    padding-top: 10px;
    padding-left: 22px;
  }
  .page {
    display: flex;
    justify-content: center;
    align-items: center;
  }
}
</style>